CC:=gcc
CFLAGS:= -g -O0 -Wall # 添加调试信息并禁用优化

log:=thirdparty/log.c thirdparty/log.h

test_log: test/test_log.c $(log)
	-$(CC) $(CFLAGS) $^ -o $@ -Ithirdparty
	-./$@
	-rm $@

app_common:=app/app_common.c app/app_common.h
test_time: test/test_time.c $(app_common) $(log)
	-$(CC) $^ -o $@ -Ithirdparty -Iapp
	-./$@
	-rm $@

json:= thirdparty/cJSON.c thirdparty/cJSON.h
test_json: test/test_json.c $(json) $(log)
	-$(CC) $^ -o $@ -Ithirdparty
	-./$@
	-rm $@

app_pool:= app/app_pool.c app/app_pool.h
test_pool: test/test_pool.c $(log) $(app_pool)
	-$(CC) $^ -o $@ -Ithirdparty -Iapp
	-./$@
	-rm $@

app_mqtt:= app/app_mqtt.c app/app_mqtt.h
test_mqtt: test/test_mqtt.c $(log) $(app_mqtt)
	-$(CC) $^ -o $@ -Ithirdparty -Iapp  -lpaho-mqtt3c
	-./$@
	-rm $@

app_message:= app/app_message.c app/app_message.h
test_message: test/test_message.c $(log) $(app_common) $(app_message) $(json)
	-$(CC) $^ -o $@ -Ithirdparty -Iapp
	-./$@
	-rm $@

app_buffer:= app/app_buffer.c app/app_buffer.h
test_buffer: test/test_buffer.c $(log) $(app_common) $(app_buffer)
	-$(CC) $^ -o $@ -Ithirdparty -Iapp
	-./$@
	-rm $@

app_device:= app/app_device.c app/app_device.h
test_device: test/test_device.c $(log) $(app_common) $(app_device) $(app_mqtt) $(app_pool) $(app_buffer) $(app_message) $(json)
	-$(CC) $^ -o $@ -Ithirdparty -Iapp -lpaho-mqtt3c
	-./$@
	-rm $@
